import React from "react";
import { NavBar } from 'antd-mobile'
// 导入 withRouter 高阶组件 
import { withRouter } from 'react-router-dom'
// 导入 props 校验包
import  PropsTypes  from "prop-types";
import './index.css'
function NavHeader ({ children, history, onLeftClick }){
  // 点击默认行为
  const defaultHandler = () => history.go(-1)
      return (
      // 顶部导航栏区域
        <NavBar className="navbar"
            mode="light"
            icon={<i className="iconfont icon-back"></i>}
            onLeftClick={ onLeftClick || defaultHandler }
            >{children}
        </NavBar>
      )
}
// 添加props检验
NavHeader.PropsTypes = {
  children:PropsTypes.string.isRequired,
  onLeftClick: PropsTypes.func
}
export default withRouter(NavHeader)